//
//  StellWeightOrLineViewModel.m
//  GLGW_Shoping
//
//  Created by yang on 2018/11/22.
//  Copyright © 2018年 yang. All rights reserved.
//

#import "StellWeightOrLineViewModel.h"
#import "StellWeightAndLineTableViewCell.h"
#import "StellWeightComintTableViewCell.h"
#import "StellEmumView.h"
#import "CaiculatorFootView.h"
#import "StellCaiculatorModel.h"

@interface StellWeightOrLineViewModel ()<UITableViewDelegate,UITableViewDataSource>{
    UITableView * self_tableView;
    UIView * super_View;
    NSArray * titArr;
    CGFloat maxWidth;
    NSString * funtionStr;
    StellCaiculatorModel * stellModel;
    StellWeightComintTableViewCell * cell_last;
}
@property (nonatomic,strong)CaiculatorFootView * footView;
@property (nonatomic,assign)NSInteger oneRwoNum;
@property (nonatomic,assign)NSInteger twoRowNum;
@end

@implementation StellWeightOrLineViewModel

-(instancetype)initWithViewToViewModel:(UITableView *)tableView theSuperView:(UIView *)superView{
    if (self = [super initWithViewToViewModel:tableView theSuperView:superView]) {
        self.oneRwoNum = 0;//记录第一个
        self.twoRowNum = 0;//记录第二个
        stellModel = [StellCaiculatorModel new];
        self_tableView = tableView;
        super_View = superView;
        tableView.height = tableView.height - kHeightProportion_In_iPhoneTriploid(44);
        tableView.mj_footer.hidden = YES;
        tableView.mj_header.hidden = YES;
        tableView.delegate = self;
        tableView.dataSource = self;
        [superView addSubview:tableView];
    }
    return self;
}

-(UIView *)createFootView{
    self.footView = [[CaiculatorFootView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, kHeightProportion_In_iPhoneTriploid(230))];
    self.footView.formulaString = funtionStr;
    return self.footView;
}
#pragma mark --- set
-(void)setCai_type:(CaiculatorType)cai_type{
    _cai_type = cai_type;
}

-(void)setModel_rowIndex:(NSInteger)model_rowIndex{
    _model_rowIndex = model_rowIndex;
    switch (_model_rowIndex) {
        case 0:{
            if (_cai_type == CaiculatorType_Weight) {
                titArr = @[@"厚度 (d)",@"宽度 (w)",@"长度 (L)"];
                funtionStr = @"理计重量W=0.00000785*d*w*L";
            }else{
                titArr = @[@"厚度 (d)",@"宽度 (w)",@"重量 (W)"];
                funtionStr = @"理计长度L=W/0.00000785*d*w";
            }
        }
            break;
        case 1:{
            if (_cai_type == CaiculatorType_Weight) {
                titArr = @[@"切面直径 (d)",@"长度 (L)"];
                funtionStr = @"理计重量W=0.00000617*d*d*L";
            }else{
                titArr = @[@"厚度 (d)",@"重量 (W)"];
                funtionStr = @"理计长度L=W/0.00000617*d*d";
            }
        }
            break;
        case 2:{
            if (_cai_type == CaiculatorType_Weight) {
                titArr = @[@"圆钢直径 (d)",@"长度 (L)"];
                funtionStr = @"理计重量W=0.000006165*d*d*L";
            }else{
                titArr = @[@"圆钢直径 (d)",@"重量 (W)"];
                funtionStr = @"理计长度L=W/0.000006165*d*d";
            }
        }
            break;
        case 3:{
            if (_cai_type == CaiculatorType_Weight) {
                titArr = @[@"高度 (h)",@"脚宽 (b)",@"腰厚 (d)",@"内面圆角半径 (r)",@"边端圆角半径 (r1)",@"长度 (L)"];
                funtionStr = @"理计重量W=0.00000785*[h*d+2*r(b-d)+0.8584*(r*r-r1*r1)]*L";
            }else{
                titArr = @[@"高度 (h)",@"脚宽 (b)",@"腰厚 (d)",@"内面圆角半径 (r)",@"边端圆角半径 (r1)",@"重量 (W)"];
                funtionStr = @"理计长度L=W/0.00000785*[h*d+2*r(b-d)+0.8584*(r*r-r1*r1)]";
            }
        }
            break;
        case 4:{
            if (_cai_type == CaiculatorType_Weight) {
                titArr = @[@"边宽 (b)",@"边厚 (d)",@"圆弧半径(R)",@"端弧半径(r)",@"长度(L)"];
                funtionStr = @"理计重量W=0.00000785*[d*(2*b-d)+0.215(R*R-2*r*r)]*L";
            }else{
                titArr = @[@"边宽 (b)",@"边厚 (d)",@"圆弧半径(R)",@"端弧半径(r)",@"重量 (W)"];
                funtionStr = @"理计长度L=W/0.00000785*[d*(2*b-d)+0.215(R*R-2*r*r)]";
            }
        }
            break;
        case 5:{
            if (_cai_type == CaiculatorType_Weight) {
                titArr = @[@"长边宽 (B)",@"短边宽 (b)",@"边厚 (d)",@"内弧半径 (R)",@"端弧半径 (r) ",@"长度 (L)"];
                funtionStr = @"理计重量\nW=0.00000785*[d*(B+b-d)+0.215(R*R-2*r*r)]*L";
            }else{
                titArr = @[@"长边宽 (B)",@"短边宽 (b)",@"边厚 (d)",@"内弧半径 (R)",@"端弧半径 (r) ",@"重量 (W)"];
                funtionStr = @"理计长度\nL=W/0.00000785*[d*(B+b-d)+0.215(R*R-2*r*r)]";
            }
        }
            break;
        case 6:
        case 7:{
            if (_cai_type == CaiculatorType_Weight) {
                titArr = @[@"高度 (h)",@"腿长 (b)",@"腰厚 (d)",@"平均腿 (t)",@"内弧半径 (R)",@"端弧半径 (r) ",@"长度 (L)"];
                if (_model_rowIndex == 6) {
                    funtionStr = @"理计重量\nW=0.00000785*[h*d+2*t(b-d)+0.349(R*R-r*r)]*L";
                }else{
                    funtionStr = @"理计重量\nW=0.00000785*[h*d+2*t(b-d)+0.8584(R*R-r*r)]*L";
                }
                
            }else{
                titArr = @[@"高度 (h)",@"腿长 (b)",@"腰厚 (d)",@"平均腿 (t)",@"内弧半径 (R)",@"端弧半径 (r) ",@"重量 (W)"];
                if (_model_rowIndex == 6) {
                    funtionStr = @"理计长度\nL=W/0.00000785*[h*d+2*t(b-d)+0.349(R*R-r*r)]";
                }else{
                    funtionStr = @"理计长度\nL=W/0.00000785*[h*d+2*t(b-d)+0.8584(R*R-r*r)]";
                }
            }
        }
            break;
        case 8:
        case 9:{
            if (_cai_type == CaiculatorType_Weight) {
                titArr = @[@"外径 (D)",@"壁厚 (S)",@"长度 (L)"];
                funtionStr = @"理计重量W=0.00002466*S(D-S)*L";
            }else{
                titArr = @[@"外径 (D)",@"壁厚 (S)",@"重量 (W)"];
                funtionStr = @"理计长度L=W/0.00002466*S(D-S)";
            }
        }
            break;
        case 10:{
            if (_cai_type == CaiculatorType_Weight) {
                titArr = @[@"厚度 (d)",@"边宽 (d)",@"长度 (L)"];
                funtionStr = @"理计重量W=0.00000785*b*d*L";
            }else{
                titArr = @[@"厚度 (d)",@"边宽 (d)",@"重量 (W)"];
                funtionStr = @"理计长度L=W/0.00000785*b*d";
            }
        }
            break;
        case 11:
        case 12:{
            if (_cai_type == CaiculatorType_Weight) {
                titArr = @[@"对边距离 (s)",@"长度 (L)"];
                funtionStr = @"理计重量W=0.000006798*s*s*L";
            }else{
                titArr = @[@"对边距离 (s)",@"重量 (W)"];
                funtionStr = @"理计长度L=W/0.000006798*s*s";
            }
        }
            break;
        case 13:{
            if (_cai_type == CaiculatorType_Weight) {
                titArr = @[@"花形",@"厚度",@"宽度 (w)",@"长度 (L)"];
                funtionStr = @"理计重量W=0.0216*L*w";
            }else{
                titArr = @[@"花形",@"厚度",@"宽度 (w)",@"重量 (W)"];
                funtionStr = @"理计长度L=W/(0.0216*w)";
            }
        }
            break;
            
        default:
            break;
    }
    NSMutableArray * mutableArr = [NSMutableArray arrayWithCapacity:0];
    for (NSString * str in titArr) {
        CGFloat strLenth = [GLGWLabel sizeWithTheText:str theLabelHeight:kHeightProportion_In_iPhoneTriploid(20) theTextFont:SYSTEMFONT(14)].width+1;
        [mutableArr addObject:@(strLenth)];
    }
    [self quickSortArray:mutableArr withLeftIndex:0 andRightIndex:titArr.count - 1];
    self_tableView.tableFooterView = [self createFootView];
    [self_tableView reloadData];
}

- (void)quickSortArray:(NSMutableArray *)array withLeftIndex:(NSInteger)leftIndex andRightIndex:(NSInteger)rightIndex
{
    if (leftIndex >= rightIndex) {//如果数组长度为0或1时返回
        return ;
    }
    NSInteger i = leftIndex;
    NSInteger j = rightIndex;
    //记录比较基准数
    NSInteger key = [array[i] floatValue];
    while (i < j) {
        while (i < j && [array[j] floatValue] >= key) {//如果比基准数大，继续查找
            j--;
        }
        array[i] = array[j];
        
        while (i < j && [array[i] floatValue] <= key) {//如果比基准数小，继续查找
            i++;
        }
        array[j] = array[i];
    }
    array[i] = @(key);
    [self quickSortArray:array withLeftIndex:leftIndex andRightIndex:i - 1];
    [self quickSortArray:array withLeftIndex:i + 1 andRightIndex:rightIndex];
//    DLog(@"------------------                   %@",array);
    maxWidth = [array[rightIndex] floatValue];
}
#pragma mark ---- 计算
-(void)comintModelCell{
    switch (_model_rowIndex) {
        case 0:{
            if (stellModel.listOne == 0 || stellModel.listTwo == 0 || stellModel.listThree == 0) {
                [GLGWProgressHUD showNotice:@"请补全必填信息" view:nil];
                return;
            }
            if (_cai_type == CaiculatorType_Weight) {
                cell_last.unitNum = 0.00000785*stellModel.listOne*stellModel.listTwo*stellModel.listThree;
            }else{
                cell_last.unitNum = stellModel.listThree/(0.00000785*stellModel.listOne*stellModel.listTwo);
            }
        }
            break;
        case 1:{
            if (stellModel.listOne == 0 || stellModel.listTwo == 0) {
                [GLGWProgressHUD showNotice:@"请补全必填信息" view:nil];
                return;
            }
            if (_cai_type == CaiculatorType_Weight) {//W=0.00000617*d*d*L
                cell_last.unitNum = 0.00000617*stellModel.listOne*stellModel.listOne*stellModel.listTwo;
            }else{//L=W/0.00000617*d*d
                cell_last.unitNum = stellModel.listTwo/(0.00000617*stellModel.listOne*stellModel.listOne);
            }
        }
            break;
        case 2:{
            if (stellModel.listOne == 0 || stellModel.listTwo == 0 || stellModel.listThree == 0) {
                [GLGWProgressHUD showNotice:@"请补全必填信息" view:nil];
                return;
            }
            if (_cai_type == CaiculatorType_Weight) {//W=0.000006165d*d*L
                cell_last.unitNum = 0.000006165*stellModel.listOne*stellModel.listOne*stellModel.listTwo;
            }else{//L=W/0.000006165d*d
                cell_last.unitNum = stellModel.listTwo/(0.000006165*stellModel.listOne*stellModel.listOne);
            }
        }
            break;
        case 3:{
            if (stellModel.listOne == 0 || stellModel.listTwo == 0 || stellModel.listThree == 0||stellModel.listFour == 0 || stellModel.listFiver == 0 || stellModel.listSix == 0) {
                [GLGWProgressHUD showNotice:@"请补全必填信息" view:nil];
                return;
            }
            if (_cai_type == CaiculatorType_Weight) {//0.00000785*[h*d+2*r(b-d)+0.8584*(r*r-r1*r1)]*L
                cell_last.unitNum = 0.00000785*(stellModel.listOne*stellModel.listThree+2*stellModel.listFour*(stellModel.listTwo - stellModel.listThree)+0.8584*(stellModel.listFour*stellModel.listFour - stellModel.listFiver*stellModel.listFiver))*stellModel.listSix;
            }else{//L=W/0.00000785*[h*d+2*r(b-d)+0.8584*(r*r-r1*r1)]
                cell_last.unitNum = stellModel.listSix/(0.00000785*(stellModel.listOne*stellModel.listThree + 2*stellModel.listFour*(stellModel.listFour*stellModel.listFour - stellModel.listFiver*stellModel.listFiver)));
            }
        }
            break;
        case 4:{
            if (stellModel.listOne == 0 || stellModel.listTwo == 0 || stellModel.listThree == 0||stellModel.listFour == 0 || stellModel.listFiver == 0) {
                [GLGWProgressHUD showNotice:@"请补全必填信息" view:nil];
                return;
            }
            if (_cai_type == CaiculatorType_Weight) {//W=0.00000785*[d*(2*b-d)+0.215(R*R-2*r*r)]*L
                cell_last.unitNum = 0.00000785*(stellModel.listTwo*(2*stellModel.listOne - stellModel.listTwo) + 0.215*(stellModel.listThree*stellModel.listThree - 2*stellModel.listFour*stellModel.listFour))*stellModel.listFiver;
            }else{// L=W/0.00000785*[d*(2*b-d)+0.215(R*R-2*r*r)]
                cell_last.unitNum = stellModel.listFiver/(0.00000785*(stellModel.listTwo*(2*stellModel.listOne - stellModel.listTwo) + 0.215*(stellModel.listThree*stellModel.listThree - 2*stellModel.listFour*stellModel.listFour)));
            }
        }
            break;
        case 5:{
            if (stellModel.listOne == 0 || stellModel.listTwo == 0 || stellModel.listThree == 0||stellModel.listFour == 0 || stellModel.listFiver == 0 || stellModel.listSix == 0) {
                [GLGWProgressHUD showNotice:@"请补全必填信息" view:nil];
                return;
            }
            if (_cai_type == CaiculatorType_Weight) {// W=0.00000785*[d*(B+b-d)+0.215(R*R-2*r*r)]*L
                cell_last.unitNum = 0.00000785*(stellModel.listThree*(stellModel.listOne+stellModel.listTwo - stellModel.listThree)+0.215*(stellModel.listFour*stellModel.listFour - 2*stellModel.listFiver*stellModel.listFiver))*stellModel.listSix;
            }else{//L=W/0.00000785*[d*(B+b-d)+0.215(R*R-2*r*r)]
                cell_last.unitNum = stellModel.listSix/(0.00000785*(stellModel.listThree*(stellModel.listOne+stellModel.listTwo - stellModel.listThree)+0.215*(stellModel.listFour*stellModel.listFour - 2*stellModel.listFiver*stellModel.listFiver)));
            }
        }
            break;
        case 6:{
            if (stellModel.listOne == 0 || stellModel.listTwo == 0 || stellModel.listThree == 0||stellModel.listFour == 0 || stellModel.listFiver == 0 || stellModel.listSix == 0 || stellModel.listSeven) {
                [GLGWProgressHUD showNotice:@"请补全必填信息" view:nil];
                return;
            }
            if (_cai_type == CaiculatorType_Weight) {//W=0.00000785*[h*d+2*t(b-d)+0.349(R*R-r*r)]*L
                cell_last.unitNum = 0.00000785*(stellModel.listOne*stellModel.listThree + 2*stellModel.listFour*(stellModel.listTwo - stellModel.listThree)+0.349*(stellModel.listFiver*stellModel.listFiver - stellModel.listSix*stellModel.listSix))*stellModel.listSeven;
            }else{//L=W/0.00000785*[h*d+2*t(b-d)+0.349(R*R-r*r)]
                cell_last.unitNum = stellModel.listSeven/(0.00000785*(stellModel.listOne*stellModel.listThree + 2*stellModel.listFour*(stellModel.listTwo - stellModel.listThree)+0.349*(stellModel.listFiver*stellModel.listFiver - stellModel.listSix*stellModel.listSix)));
            }
        }
            break;
        case 7:{
            if (stellModel.listOne == 0 || stellModel.listTwo == 0 || stellModel.listThree == 0||stellModel.listFour == 0 || stellModel.listFiver == 0 || stellModel.listSix == 0 || stellModel.listSeven) {
                [GLGWProgressHUD showNotice:@"请补全必填信息" view:nil];
                return;
            }
            if (_cai_type == CaiculatorType_Weight) {//W=0.00000785*[h*d+2*t(b-d)+0.8584(R*R-r*r)]*L
                cell_last.unitNum = 0.00000785*(stellModel.listOne*stellModel.listThree +2*stellModel.listFour*(stellModel.listTwo - stellModel.listThree)+0.8584*(stellModel.listFiver*stellModel.listFiver - stellModel.listSix*stellModel.listSix))*stellModel.listSeven;
            }else{//L=W/0.00000785*[h*d+2*t(b-d)+0.8584(R*R-r*r)]
                cell_last.unitNum = stellModel.listSeven/(0.00000785*(stellModel.listOne*stellModel.listThree +2*stellModel.listFour*(stellModel.listTwo - stellModel.listThree)+0.8584*(stellModel.listFiver*stellModel.listFiver - stellModel.listSix*stellModel.listSix)));
            }
        }
            break;
        case 8:
        case 9:{
            if (stellModel.listOne == 0 || stellModel.listTwo == 0 || stellModel.listThree == 0) {
                [GLGWProgressHUD showNotice:@"请补全必填信息" view:nil];
                return;
            }
            if (_cai_type == CaiculatorType_Weight) {//W=0.00002466*S(D-S)*L
                cell_last.unitNum = 0.00002466*stellModel.listTwo*(stellModel.listOne - stellModel.listTwo)*stellModel.listThree;
                
            }else{// L=W/0.00002466*S(D-S)
                cell_last.unitNum = stellModel.listThree/(0.00002466*stellModel.listTwo*(stellModel.listOne - stellModel.listTwo));
            }
        }
            break;
        case 10:{
            if (stellModel.listOne == 0 || stellModel.listTwo == 0 || stellModel.listThree == 0) {
                [GLGWProgressHUD showNotice:@"请补全必填信息" view:nil];
                return;
            }
            if (_cai_type == CaiculatorType_Weight) {//W=0.00000785*b*d*L
                cell_last.unitNum = 0.00000785*stellModel.listOne*stellModel.listTwo*stellModel.listThree;
            }else{//L=W/0.00000785*b*d
                cell_last.unitNum = stellModel.listThree/(0.00000785*stellModel.listOne*stellModel.listTwo);
            }
        }
            break;
        case 11:
        case 12:{
            if (stellModel.listOne == 0 || stellModel.listTwo == 0) {
                [GLGWProgressHUD showNotice:@"请补全必填信息" view:nil];
                return;
            }
            if (_cai_type == CaiculatorType_Weight) {//W=0.000006798*s*s*L
                cell_last.unitNum = 0.000006798*stellModel.listOne*stellModel.listOne*stellModel.listTwo;
            }else{//L=W/0.000006798*s*s
                cell_last.unitNum = stellModel.listTwo/(0.000006798*stellModel.listOne*stellModel.listOne);
            }
        }
            break;
        case 13:{
            if (stellModel.listThree == 0 || stellModel.listFour == 0) {
                [GLGWProgressHUD showNotice:@"请填写完整" view:nil];
                return;
            }
            [self jiSuanComint];
        }
            break;
            
            
        default:
            break;
    }
}
#pragma mark -- UITableViewDelegate,UITableViewDataSource
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return titArr.count + 1;
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.row == titArr.count) {
        return kHeightProportion_In_iPhoneTriploid(126);
    }else{
        return kHeightProportion_In_iPhoneTriploid(59);
    }
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    BaseTableViewCell * cell;
    if (indexPath.row == titArr.count) {
        StellWeightComintTableViewCell * cell_comint = [StellWeightComintTableViewCell cellWithTableView:tableView];
        cell_last = cell_comint;
        cell_comint.cai_type = _cai_type;
        cell_comint.Block_StellJiSuan = ^{
            [self comintModelCell];
        };
        cell = cell_comint;
    }else{
        StellWeightAndLineTableViewCell * cell_Weight = [StellWeightAndLineTableViewCell cellWithTableView:tableView];
        kWeakSelf(cell_Weight);
        cell_Weight.Block_EmumAction = ^{
            [self btnTwoClickedtable:tableView theclickCell:weakcell_Weight];
        };
        cell_Weight.rowIndex = indexPath.row;
        cell_Weight.collectionRow = _model_rowIndex;
        cell_Weight.cai_model = stellModel;
        cell_Weight.leftTitleLabelWidth = maxWidth;
        cell_Weight.leftTitStr = titArr[indexPath.row];
        if (indexPath.row == titArr.count - 1) {
            cell_Weight.type_m = _cai_type;
            cell_Weight.isLastCell = YES;
        }
        cell = cell_Weight;
    }
    return cell;
}


-(void)btnTwoClickedtable:(UITableView *)self_tableView theclickCell:(StellWeightAndLineTableViewCell *)click_cell{
    NSIndexPath *indexPath = [self_tableView indexPathForCell:click_cell];
    //获取cell在屏幕中位置
    CGRect rectInTableView = [self_tableView rectForRowAtIndexPath:indexPath];//cell在tabview的尺寸
    CGRect rect = [self_tableView convertRect:rectInTableView toView:[self_tableView superview]];
    StellEmumView * emumView;
    if (indexPath.row == 0) {
        emumView = [[StellEmumView alloc] initPopupEmumview:@[@"菱形",@"扁豆形",@"圆豆形"] theCGRect:rect];
    }else{
        emumView = [[StellEmumView alloc] initPopupEmumview:@[@(2.5),@(3),@(3.5),@(4),@(4.5),@(5),@(5.5),@(6),@(7),@(8)] theCGRect:rect];
    }
    emumView.Block_SelectText = ^(NSString * _Nullable s_str, NSInteger row) {
        if (indexPath.row == 0) {
            self.oneRwoNum = row;
        }else{
            self.twoRowNum = row;
        }
        click_cell.textFieldStr = s_str;
        [self jiSuanComint];
    };
}

-(double)formulaInputWeight:(CGFloat)c_num{
    return c_num*stellModel.listThree*stellModel.listFour;
}

-(double)formulaInputLenght:(CGFloat)c_num{
    return stellModel.listFour/(c_num*stellModel.listThree);
}


-(void)jiSuanComint{
    switch (self.twoRowNum) {
        case 0:{
            if (self.oneRwoNum == 0) {
                if (self.cai_type == CaiculatorType_Weight) {
                    self.footView.formulaString = @"理计重量 W=0.0216*L*w";
                    cell_last.unitNum = [self formulaInputWeight:0.0216];
                }else{
                    self.footView.formulaString = @"理计长度L=W/(0.0216*w)";
                    cell_last.unitNum = [self formulaInputLenght:0.0216];
                }
            }else if(self.oneRwoNum == 1){
                if (self.cai_type == CaiculatorType_Weight) {
                    self.footView.formulaString = @"理计重量 W=0.0213*L*w";
                    cell_last.unitNum = [self formulaInputWeight:0.0213];
                }else{
                    self.footView.formulaString = @"理计长度 L=W/(0.0213*w)";
                    cell_last.unitNum = [self formulaInputLenght:0.0213];
                }
            }else{
                if (self.cai_type == CaiculatorType_Weight) {
                    self.footView.formulaString = @"理计重量 W=0.0211*L*w";
                    cell_last.unitNum = [self formulaInputWeight:0.0211];
                }else{
                    self.footView.formulaString = @"理计长度 L=W/(0.0211*w)";
                    cell_last.unitNum = [self formulaInputLenght:0.0211];
                }
            }
        }
            break;
        case 1:{
            if (self.oneRwoNum == 0) {
                if (self.cai_type == CaiculatorType_Weight) {
                    self.footView.formulaString = @"理计重量 W=0.0256*L*w";
                    cell_last.unitNum = [self formulaInputWeight:0.0256];
                }else{
                    self.footView.formulaString = @"理计长度 L=W/(0.0256*w)";
                    cell_last.unitNum = [self formulaInputLenght:0.0256];
                }
            }else if(self.oneRwoNum == 1){
                if (self.cai_type == CaiculatorType_Weight) {
                    self.footView.formulaString = @"理计重量 W=0.0244*L*w";
                    cell_last.unitNum = [self formulaInputWeight:0.0244];
                }else{
                    self.footView.formulaString = @"理计长度 L=W/(0.0244*w)";
                    cell_last.unitNum = [self formulaInputLenght:0.0244];
                }
            }else{
                if (self.cai_type == CaiculatorType_Weight) {
                    self.footView.formulaString = @"理计重量 W=0.0243*L*w";
                    cell_last.unitNum = [self formulaInputWeight:0.0243];
                }else{
                    self.footView.formulaString = @"理计长度 L=W/(0.0243*w)";
                    cell_last.unitNum = [self formulaInputLenght:0.0243];
                }
            }
        }
            break;
        case 2:{
            if (self.oneRwoNum == 0) {
                if (self.cai_type == CaiculatorType_Weight) {
                    self.footView.formulaString = @"理计重量 W=0.0295*L*w";
                    cell_last.unitNum = [self formulaInputWeight:0.0295];
                }else{
                    self.footView.formulaString = @"理计长度 L=W/(0.0295*w)";
                    cell_last.unitNum = [self formulaInputLenght:0.0295];
                }
            }else if(self.oneRwoNum == 1){
                if (self.cai_type == CaiculatorType_Weight) {
                    self.footView.formulaString = @"理计重量 W=0.0284*L*w";
                    cell_last.unitNum = [self formulaInputWeight:0.0284];
                }else{
                    self.footView.formulaString = @"理计长度 L=W/(0.0284*w)";
                    cell_last.unitNum = [self formulaInputLenght:0.0284];
                }
            }else{
                if (self.cai_type == CaiculatorType_Weight) {
                    self.footView.formulaString = @"理计重量 W=0.0283*L*w";
                    cell_last.unitNum = [self formulaInputWeight:0.0283];
                }else{
                    self.footView.formulaString = @"理计长度 L=W/(0.0283*w)";
                    cell_last.unitNum = [self formulaInputLenght:0.0283];
                }
            }
        }
            break;
        case 3:{
            if (self.oneRwoNum == 0) {
                if (self.cai_type == CaiculatorType_Weight) {
                    self.footView.formulaString = @"理计重量 W=0.0334*L*w";
                    cell_last.unitNum = [self formulaInputWeight:0.0334];
                }else{
                    self.footView.formulaString = @"理计长度 L=W/(0.0334*w)";
                    cell_last.unitNum = [self formulaInputLenght:0.0334];
                }
            }else if(self.oneRwoNum == 1){
                if (self.cai_type == CaiculatorType_Weight) {
                    self.footView.formulaString = @"理计重量 W=0.0324*L*w";
                    cell_last.unitNum = [self formulaInputWeight:0.0324];
                }else{
                    self.footView.formulaString = @"理计长度 L=W/(0.0324*w)";
                    cell_last.unitNum = [self formulaInputLenght:0.0324];
                }
            }else{
                if (self.cai_type == CaiculatorType_Weight) {
                    self.footView.formulaString = @"理计重量 W=0.0323*L*w";
                    cell_last.unitNum = [self formulaInputWeight:0.0323];
                }else{
                    self.footView.formulaString = @"理计长度 L=W/(0.0323*w)";
                    cell_last.unitNum = [self formulaInputLenght:0.0323];
                }
            }
        }
            break;
        case 4:{
            if (self.oneRwoNum == 0) {
                if (self.cai_type == CaiculatorType_Weight) {
                    self.footView.formulaString = @"理计重量 W=0.0373*L*w";
                    cell_last.unitNum = [self formulaInputWeight:0.0373];
                }else{
                    self.footView.formulaString = @"理计长度 L=W/(0.0373*w)";
                    cell_last.unitNum = [self formulaInputLenght:0.0373];
                }
            }else if(self.oneRwoNum == 1){
                if (self.cai_type == CaiculatorType_Weight) {
                    self.footView.formulaString = @"理计重量 W=0.0364*L*w";
                    cell_last.unitNum = [self formulaInputWeight:0.0364];
                }else{
                    self.footView.formulaString = @"理计长度 L=W/(0.0364*w)";
                    cell_last.unitNum = [self formulaInputLenght:0.0364];
                }
            }else{
                if (self.cai_type == CaiculatorType_Weight) {
                    self.footView.formulaString = @"理计重量 W=0.0362*L*w";
                    cell_last.unitNum = [self formulaInputWeight:0.0362];
                }else{
                    self.footView.formulaString = @"理计长度 L=W/(0.0362*w)";
                    cell_last.unitNum = [self formulaInputLenght:0.0362];
                }
            }
        }
            break;
        case 5:{
            if (self.oneRwoNum == 0) {
                if (self.cai_type == CaiculatorType_Weight) {
                    self.footView.formulaString = @"理计重量 W=0.0423*L*w";
                    cell_last.unitNum = [self formulaInputWeight:0.0423];
                }else{
                    self.footView.formulaString = @"理计长度 L=W/(0.0423*w)";
                    cell_last.unitNum = [self formulaInputLenght:0.0423];
                }
            }else if(self.oneRwoNum == 1){
                if (self.cai_type == CaiculatorType_Weight) {
                    self.footView.formulaString = @"理计重量 W=0.0405*L*w";
                    cell_last.unitNum = [self formulaInputWeight:0.0405];
                }else{
                    self.footView.formulaString = @"理计长度 L=W/(0.0405*w)";
                    cell_last.unitNum = [self formulaInputLenght:0.0405];
                }
            }else{
                if (self.cai_type == CaiculatorType_Weight) {
                    self.footView.formulaString = @"理计重量 W=0.0402*L*w";
                    cell_last.unitNum = [self formulaInputWeight:0.0402];
                }else{
                    self.footView.formulaString = @"理计长度 L=W/(0.0402*w)";
                    cell_last.unitNum = [self formulaInputLenght:0.0402];
                }
            }
        }
            break;
        case 6:{
            if (self.oneRwoNum == 0) {
                if (self.cai_type == CaiculatorType_Weight) {
                    self.footView.formulaString = @"理计重量 W=0.0441*L*w";
                    cell_last.unitNum = [self formulaInputWeight:0.0441];
                }else{
                    self.footView.formulaString = @"理计长度 L=W/(0.0462*w)";
                    cell_last.unitNum = [self formulaInputLenght:0.0441];
                }
            }else if(self.oneRwoNum == 1){
                if (self.cai_type == CaiculatorType_Weight) {
                    self.footView.formulaString = @"理计重量 W=0.0443*L*w";
                    cell_last.unitNum = [self formulaInputWeight:0.0443];
                }else{
                    self.footView.formulaString = @"理计长度 L=W/(0.0443*w)";
                    cell_last.unitNum = [self formulaInputLenght:0.0443];
                }
            }else{
                if (self.cai_type == CaiculatorType_Weight) {
                    self.footView.formulaString = @"理计重量 W=0.0441*L*w";
                    cell_last.unitNum = [self formulaInputWeight:0.0441];
                }else{
                    self.footView.formulaString = @"理计长度 L=W/(0.0441*w)";
                    cell_last.unitNum = [self formulaInputLenght:0.0441];
                }
            }
        }
            break;
        case 7:{
            if (self.oneRwoNum == 0) {
                if (self.cai_type == CaiculatorType_Weight) {
                    self.footView.formulaString = @"理计重量 W=0.0501*L*w";
                    cell_last.unitNum = [self formulaInputWeight:0.0501];
                }else{
                    self.footView.formulaString = @"理计长度 L=W/(0.0501*w)";
                    cell_last.unitNum = [self formulaInputLenght:0.0501];
                }
            }else if(self.oneRwoNum == 1){
                if (self.cai_type == CaiculatorType_Weight) {
                    self.footView.formulaString = @"理计重量 W=0.0484*L*w";
                    cell_last.unitNum = [self formulaInputWeight:0.0484];
                }else{
                    self.footView.formulaString = @"理计长度 L=W/(0.0484*w)";
                    cell_last.unitNum = [self formulaInputLenght:0.0484];
                }
            }else{
                if (self.cai_type == CaiculatorType_Weight) {
                    self.footView.formulaString = @"理计重量 W=0.0481*L*w";
                    cell_last.unitNum = [self formulaInputWeight:0.0481];
                }else{
                    self.footView.formulaString = @"理计长度 L=W/(0.0481*w)";
                    cell_last.unitNum = [self formulaInputLenght:0.0481];
                }
            }
        }
            break;
        case 8:{
            if (self.oneRwoNum == 0) {
                if (self.cai_type == CaiculatorType_Weight) {
                    self.footView.formulaString = @"理计重量 W=0.059*L*w";
                    cell_last.unitNum = [self formulaInputWeight:0.059];
                }else{
                    self.footView.formulaString = @"理计长度L=W/(0.059*w)";
                    cell_last.unitNum = [self formulaInputLenght:0.059];
                }
            }else if(self.oneRwoNum == 1){
                if (self.cai_type == CaiculatorType_Weight) {
                    self.footView.formulaString = @"理计重量 W=0.0526*L*w";
                    cell_last.unitNum = [self formulaInputWeight:0.0526];
                }else{
                    self.footView.formulaString = @"理计长度 L=W/(0.0526*w)";
                    cell_last.unitNum = [self formulaInputLenght:0.0526];
                }
            }else{
                if (self.cai_type == CaiculatorType_Weight) {
                    self.footView.formulaString = @"理计重量 W=0.0524*L*w";
                    cell_last.unitNum = [self formulaInputWeight:0.0524];
                }else{
                    self.footView.formulaString = @"理计长度 L=W/(0.0524*w)";
                    cell_last.unitNum = [self formulaInputLenght:0.0524];
                }
            }
        }
            break;
        case 9:{
            if (self.oneRwoNum == 0) {
                if (self.cai_type == CaiculatorType_Weight) {
                    self.footView.formulaString = @"理计重量 W=0.0668*L*w";
                    cell_last.unitNum = [self formulaInputWeight:0.0668];
                }else{
                    self.footView.formulaString = @"理计长度 L=W/(0.0668*w)";
                    cell_last.unitNum = [self formulaInputLenght:0.0668];
                }
            }else if(self.oneRwoNum == 1){
                if (self.cai_type == CaiculatorType_Weight) {
                    self.footView.formulaString = @"理计重量 W=0.0564*L*w";
                    cell_last.unitNum = [self formulaInputWeight:0.0564];
                }else{
                    self.footView.formulaString = @"理计长度 L=W/(0.0564*w)";
                    cell_last.unitNum = [self formulaInputLenght:0.0564];
                }
            }else{
                if (self.cai_type == CaiculatorType_Weight) {
                    self.footView.formulaString = @"理计重量 W=0.0562*L*w";
                    cell_last.unitNum = [self formulaInputWeight:0.0562];
                }else{
                    self.footView.formulaString = @"理计长度 L=W/(0.0562*w)";
                    cell_last.unitNum = [self formulaInputLenght:0.0562];
                }
            }
        }
            break;
            
        default:
            break;
    }
}

@end
